package com.cost.controller;

import com.cost.service.CostInvoiceService;
import com.cost.vo.Entity;
import com.rmb.mart.entity.cost.CostInvoice;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CostInvoice)表控制层
 *
 * @author makejava
 * @since 2021-01-20 14:04:20
 */
@RestController
@RequestMapping("costInvoice")
public class CostInvoiceController {
    /**
     * 服务对象
     */
    @Resource
    private CostInvoiceService costInvoiceService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public CostInvoice selectOne(Long id) {
        return this.costInvoiceService.queryById(id);
    }

    /**
     * 查询所用数据
     *
     * @return 所用数据
     */
    @GetMapping("selectAll")
    public List<CostInvoice> selectAll(){
        return this.costInvoiceService.selectAll();
    }

    /**
     * 分页查询
     *
     * @param offset 初始页
     * @param limit 每页
     * @return 每页数据
     */
    @GetMapping("selectAllByLimit")
    public List<CostInvoice> selectAllByLimit(int offset, int limit){
        return this.costInvoiceService.queryAllByLimit(offset,limit);
    }

    /**
     * 条件查询
     * @param costInvoice 条件
     * @return 条件查询数据
     */
    @PostMapping("selectAllCondition")
    public List<CostInvoice> selectAllCondition(@RequestBody CostInvoice costInvoice){
        return this.costInvoiceService.selectAllCondition(costInvoice);
    }

    /**
     * 需要发票
     * @param entity 发票信息
     */
    @PostMapping("insertDemo")
    public void insertDemo(@RequestBody Entity entity){
        this.costInvoiceService.insertDemo(entity);
    }
}